home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
ARGONET
/
PD
/
DESKTOP
/
CLIPBOARD.ZIP
/
!Clipboard
/
!RunImage
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1998-09-17
|
13KB
|
546 lines
>Prog:!Clipboard.!RunImage
$+" (error code "+
scrap 256
InternalHandle% = -&11223344
TASK 5,temp_name 12, menu_block 28+24*2
$TASK="TASK"
"Wimp_Initialise",200,!TASK,"Clipboard"
,Handle%
"Wimp_OpenTemplate",,"<Obey$Dir>.Templates"
block 1024
$temp_name="Info"
"Wimp_LoadTemplate",,0,,,-1,temp_name,0
,,IndSize%
indbuf IndSize%
"Wimp_LoadTemplate",,block,indbuf,indbuf+IndSize%+1,-1,temp_name,0
"Wimp_CreateWindow",,block
InfoWindow%
$temp_name="Main"
"Wimp_LoadTemplate",,0,,,-1,temp_name,0
,,IndSize%
indbuf IndSize%
"Wimp_LoadTemplate",,block,indbuf,indbuf+IndSize%+1,-1,temp_name,0
"Wimp_CreateWindow",,block
MainWindow%
block!0=-1
block!4=0
block!8=0
block!12=76
block!16=68
block!20=%11000000011010
$(block+24)="!Clipboard"
"Wimp_CreateIcon",,block
SaveDragTo%=-1
=Quit%=
:Owner%=-1:OurFile$="":SaveRef%=-1:SaveDragRef%=-1
init_menu
examine_clipboard
"Wimp_Poll",%110001,block
Reason%
Reason%
&-
2 :
"Wimp_OpenWindow",,block
'.
3 :
"Wimp_CloseWindow",,block
(5
6 :
block!8<>2
mouse_click
)
7 :
user_drag_box
*!
8 :
block!24=13
+9
save_clipboard(
read_data(3),
-'
block!24=&1B
.,
close(MainWindow%)
07
"Wimp_ProcessKey", block!24
3'
9 :
block!0=1
Quit%=
4$
17,18 :
message(block!16)
19 :
Quit%
"Wimp_CloseDown",Handle%,!TASK
"OS_Exit"
message(Code%)
Code%
0 : Quit%=
1 :
block!12=SaveRef%
save_ack_to(SavePath$):
@?
block!12=MyRef%
block!24=InternalHandle%
A'
block!12<>MyRef%
B;
pe("Bad yourref in DataSave message")
D2
block!24<>InternalHandle%
E<
pe("Bad handle in DataSave message")
G,
proto("Found owner")
K0
set_text(3,
strip(block+44))
L=
set_text(6,
name(block!4)):Owner%=block!4
M# Type$=
~block!40
N,
set_text(2,
type(Type$))
O3
set_ind(0,"sfile_"+Type$+";r2")
P4
"Wimp_GetCaretPosition",,block
Q<
block!0=MainWindow%
put_caret(block)
R6
unshade(3):
unshade(0):
unshade(4)
S*
unshade(6):
unshade(2)
2 :
block!12=SaveDragRef%
VL
Dragged-to app wants the file - grab it from clip owner
W' SaveDragRef%=block!8
Y5
Ack the message whatever happens
Z* block!12 = SaveDragRef%
[<
"Wimp_SendMessage", 19, block, block!4
]8
save_clipboard(
strip(block+44),
^%
Owner%=Handle%
_+
We own it - ack now.
`#
send_save_ack
c6
copy(OurFile$,
strip(block + 44))
d# Request%=block!4
e# block!12=block!8
block!16=3
gJ
"XOS_File",23,OurFile$
Ob%,,,,Size%,,Type% ;Flags%
h-
(Flags%
%1)
Ob%<>1
i.
pe("Bad clipboard file")
k# block!36=Size%
l# block!40=Type%
m<
"Wimp_SendMessage",17,block,Request%
3 :
(block!12)=SaveRef%
q&
SaveDragTo%<>-1
r* SaveDragFrom%=block!4
s) SaveFromRef%=block!8
u&
Ack the message
v' block!12 = block!8
wD
"Wimp_SendMessage", 19, block, SaveDragFrom%
yJ block!12=SaveDragRef% :
Pass message on to dest app
z?
"Wimp_SendMessage",18,block,SaveDragTo%
{) SaveDragRef%=block!8
|6
proto("Asking app to load data")
#
claim_clipboard
, OurFile$=
strip(block+44)
(
set_text(3,OurFile$)
:
set_text(6,"Clipboard"):Owner%=Handle%
%
proto("I own it")
# Type$=
~block!40
,
set_text(2,
type(Type$))
3
set_ind(0,"sfile_"+Type$+";r2")
D
"Wimp_GetCaretPosition",,block
G
block!0=MainWindow%
block!0=-1:
put_caret(block)
6
unshade(3):
unshade(0):
unshade(4)
>
unshade(6):
unshade(2):
front(MainWindow%)
4 :
SaveDragTo%<>-1
( block!12=SaveFromRef%
?
"Wimp_SendMessage",17,block,SaveDragFrom%
! SaveDragTo%=-1
&F :
((block!20)
D
block!4<>Handle%
Owner%=-1:
examine_clipboard
&10 :
MyRef%<>block!8
%
Owner%=Handle%
2
proto("Sending data myself")
% Request%=block!4
% block!12=block!8
3
"Wimp_SendMessage",19,block
L
"XOS_File",23,OurFile$
Ob%,,,,Size%,,Type% ;Flags%
/
(Flags%
%1)
Ob%<>1
4
report("Bad clipboard file")
% block!36=Size%
! block!16=1
% block!40=Type%
, Leaf$=
leaf(OurFile$)
+ $(block+44)=Leaf$+
2 block!0=44+(
(Leaf$)+4)
>
"Wimp_SendMessage",17,block,Request%
block!16=4
pe("Receiver died!"):SaveDragTo%=-1:
block!8=SaveDragRef%
proto("App not interested"):
block!8<>MyRef%
block!16<>&10
set_text(3,"None")
set_text(6,"-"):Owner%=-1:
proto("No clipboard")
set_text(2,"-")
Type$="xxx"
set_ind(0,"sfile_xxx;r2")
"Wimp_GetCaretPosition",,block
block!0=MainWindow%
block!0=-1:
put_caret(block)
shade(3):
shade(0):
shade(4)
unshade(6):
unshade(2)
examine_clipboard
Owner%=Handle%
block!0=44
block!12=0
block!16=&10
block!20=MainWindow%
;block!24=InternalHandle% :
Help find protocol errors.
block!36=4
block!40=-1
"Wimp_SendMessage",18,block,0
MyRef%=block!8
proto("Looking for owner")
put_caret(b)
"Wimp_SetCaretPosition",b!0,b!4,b!8,b!12,b!16,b!20
name(Handle%)
"XTaskManager_TaskNameFromHandle",Handle%
NamePtr% ;Flags%
Flags%
="???"
strip(NamePtr%)
strip(Addr%)
A$=""
?Addr%>31
A$+=
(?Addr%)
Addr%+=1
set_text(Icon%,Text$)
block!512=MainWindow%
block!516=Icon%
"Wimp_GetIconState",,block+512
Addr%=block!(28+512)
Size%=block!(36+512)
$Addr%=
Text$,Size%-1)
read_data(Icon%)
block!512=MainWindow%
block!516=Icon%
"Wimp_GetIconState",,block+512
strip(block!(28+512))
set_ind(Icon%,Text$)
(Text$)<>12
Text$="sfile_xxx;r2"
block!512=MainWindow%
block!516=Icon%
"Wimp_GetIconState",,block+512
Addr%=block!(32+512)
$Addr%=Text$
type(Hex$)
"XOS_ReadVarVal","File$Type_"+Hex$,block+512,512,0,3
,,Len%;Flags%
Flags%
=Hex$
block?(Len%+512)=0
strip(block+512)
mouse_click
Window%=block!12
Window%
-2 :
toggle(MainWindow%)
MainWindow%:
block!16=4
save_clipboard(
read_data(3),-1,0)
4
block!16=0
drag_icon(0)
InfoWindow%: block!0=InfoWindow%
! block!4=1
0
"Wimp_DragBox",,block
block!12=-2
Height%=96+44*2
Height%=block!4+48
"Wimp_CreateMenu",,menu_block,block!0-48,Height%
front(Window%)
block!512=Window%
"Wimp_GetWindowState",,block+512
block!(512+28)=-1
"Wimp_OpenWindow",,block+512
put_caret_in(3)
close(Window%)
block!512=Window%
"Wimp_CloseWindow",,block+512
toggle(Window%)
block!512=Window%
"Wimp_GetWindowState",,block+512
block!(512+32)
(1<<17)
"Wimp_CloseWindow",,block+512
block!(512+28)=-1
"Wimp_OpenWindow",,block+512
put_caret_in(3)
examine_clipboard
shade(Icon%)
block!512=MainWindow%
block!516=Icon%
block!520=1<<22
block!524=1<<22
"Wimp_SetIconState",,block+512
unshade(Icon%)
block!512=MainWindow%
block!516=Icon%
block!520=0
block!524=1<<22
"Wimp_SetIconState",,block+512
claim_clipboard
bk=block+512
!bk=24
bk!12=0
bk!16=&f
bk!20=%100
"Wimp_SendMessage",18,bk,0
report(Error$)
block!512=0
$(block+516)=Error$
"Wimp_ReportError",block+512,%101,"Clipboard"
leaf(Text$)
Dot%=0
A%=1
(Text$)
Text$,A%,1)="."
Dot%=A%
Text$,Dot%+1)
save_clipboard(S$,Check%,UseWindow%)
SavePath$=S$
Check%
SavePath$,".")=0
report("To save, drag icon to a directory viewer"):
Owner%=Handle%
copy(OurFile$, SavePath$):
block!0=44
block!12=0
P+block!16=&10 :
Request clipboard data
UseWindow% =
block!20=-3
block!24=InternalHandle%
block!28=640
block!32=512
block!36=4
block!40=-1
"Wimp_SendMessage",18,block,Owner%
SaveRef%=block!8
proto("Asking owner to save")
save_ack_to(Path$)
Request%=block!4
block!12=block!8
a0block!16=2 :
Please save file to SavePath$
$(block+44)=SavePath$+
c#block!0=(
(SavePath$)+48)
"Wimp_SendMessage",17,block,Request%
SaveRef%=block!8
put_caret_in(Icon%)
block!512=MainWindow%
block!516=Icon%
"Wimp_GetIconState",,block+512
block!(512+24)
(1<<22)
"Wimp_SetCaretPosition",MainWindow%,Icon%,&10000,0,-1,-1
drag_icon(Icon%)
bk=block+512
bk!0=MainWindow%
bk!4=Icon%
"Wimp_GetIconState",,bk
MinX%=bk!8
MinY%=bk!12
MaxX%=bk!16
MaxY%=bk!20
"Wimp_GetWindowState",,bk
Xoff%=bk!4
bk!0=MinX%+Xoff%
bk!4=MinY%+bk!16
bk!8=MaxX%+Xoff%
bk!12=MaxY%+bk!16
"DragASprite_Start",%11000101,1,"file_"+Type$,bk
user_drag_box
"DragASprite_Stop"
"Wimp_GetPointerInfo",,block
block!12=MainWindow%
DestWin%=block!12
DestIcon%=block!16
Name$=
leaf(
read_data(3))
block!28=block!0
block!32=block!4
block!0=(48+
(Name$))
block!12=0
4block!16=1 :
Ask dest app if it wants the file
block!20=DestWin%
block!24=DestIcon%
block!36=0
block!40=
("&"+Type$)
$(block+44)=Name$+
"Wimp_SendMessage",18,block,DestWin%,DestIcon%
,,SaveDragTo%
SaveDragRef%=block!8
proto("Offering data")
send_save_ack
block!12=SaveDragRef%
)block!16=3 :
File can now be loaded
"Wimp_SendMessage",17,block,SaveDragTo%
SaveDragTo%=-1
init_menu
$menu_block="Clipboard"+
menu_block!12=&070207
menu_block!16=16*7
menu_block!20=44
menu_block!24=0
menu_block!28=0
menu_block!32=InfoWindow%
menu_block!36=&07000031
$(menu_block+40)="Info"
menu_block!52=&80
menu_block!56=-1
menu_block!60=&07000031
$(menu_block+64)="Quit"
copy(From$, To$)
"XOS_FSControl", 26, From$, To$, %10
r0 ;v%
"Wimp_ReportError", r0, %101, "Clipboard"
Report a protocol error
pe(Error$)
scrap!0 = MainWindow%
scrap!4 = 7
"Wimp_GetIconState", 0, scrap
$(scrap!28) = Error$
scrap!8 = &0b000000
scrap!12 = &0f000000
"Wimp_SetIconState", 0, scrap
"Wimp_GetWindowState", 0, scrap
scrap!32
(1 << 16)
Window is already open - bring it to the front
and enlarge it to show the error.
scrap!8 -= 128
scrap!28 = -1
"Wimp_OpenWindow", 0, scrap
proto(Mess$)
scrap!0 = MainWindow%
scrap!4 = 7
"Wimp_GetIconState", 0, scrap
$(scrap!28) = Mess$
scrap!8 = &07000000
scrap!12 = &0f000000
"Wimp_SetIconState", 0, scrap